package com.mrd.gtimpframe.service;

import java.util.List;
import java.util.Map;

import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import com.mrd.gtimp.business.entity.HgData;

/**
 * 缓存方法服务类
 * 
 * @category srping cache不能在方法内部调用，所以把内部调用的方法分离出来
 * @author han
 *
 */
@Service
public class CacheService {

  @Cacheable(value = "hgdataCover", key = "'hgdataCover_' + #type + '_' + #source")
  public String hgdataCover(Map<String, List<HgData>> hgdataMap, String type, String source) {
    List<HgData> hgDatas = hgdataMap.get(type);
    for (HgData hgData : hgDatas) {
      if (hgData.getName().equals(source)) {
        return hgData.getCode();
      }
    }
    return "";
  }

}
